<?php

include("common/common.php");
session_start();

$email=$_POST["email"];
$passwd=$_POST["passwd"];

$data['email'] = $email;
$data['psword'] = $passwd;

$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();

$sql = "SELECT email, psword FROM `user_info`
WHERE email = '".$email."' and psword='".$passwd."'";
$record = $db->query_first($sql);
$db->close();

if (is_null($record['email'])){
	setcookie("_user", "", time()-3600);
	$_SESSION["logtag"]=1;
}else{
	setcookie('_user', $email,time()+315360000);
	$_SESSION["logtag"]=0;
}
$lasturl = $_SESSION['currenturl'];
redirect($lasturl);
?>
